SUBROUTINE MAKETABLE_A3
     * Create a simple table and populate it with data from
     * a Reality file. Draw borders round the cells.
     * Format the columns using CSS classes.

     * Include the RealWeb definitions.
     INCLUDE #RW.INCLUDE.DEFS FROM /SYSFILES/REALWEB,BP

     EQU AM TO CHAR(254)
     EQU VM TO CHAR(253)
     EQU TAB TO CHAR(9)

     * Get the URL of the Reality item server.
     STYLESHEET = ""
     CALL RW_GET_PARAM("__isurl", STYLESHEET)
     * Specify the location of the stylesheet.
     STYLESHEET = STYLESHEET : "/REALWEB-ITEMS/table.css"

     * Start the HTML page.
     CALL RW_START_HTML_PAGE("RWA_MAKE_TABLE Example 3", "", STYLESHEET, "", "")

     HTML = "Hotel Guests"
     CALL RWS_HEADING(HTML, 2, "")

     * Assemble some data to go in the table.
     *   Get some data to insert.
     PERFORM "SORT-SPREAD GUESTS < '200' " : ...
        "ROOM NAME ADDRESS CITY STATE ZIP ID-SUPP" ...
        CAPTURING aData
     *   The headings are in the second attribute.
     DEL aData<1>
     aHeadings = aData<1>
     *   SORT-SPREAD returns tab-separated data; we need a dynamic array.
     aHeadings = CHANGE(aHeadings, TAB, AM)
     *   The data is in the third attribute onwards.
     DEL aData<1>
     *   SORT-SPREAD returns tab-separated data; we need a dynamic array.
     aData = CHANGE(aData, TAB, VM)

     * Give alternate columns a different style.
     aDataFormat = ""
     FOR I = 1 TO DCOUNT(aHeadings, AM)
        IF MOD(INT(I),2) THEN
           aDataFormat<I> = "gray"
        END ELSE
           aDataFormat<I> = "white"
        END
     NEXT I

     * Give the table a border.
     aClass = ""
     aClass<2> = "border"

     * Create the table.
     CALL RWA_MAKE_TABLE(HTML, aHeadings, aData, aDataFormat, aClass, RWD_IGNORE_EMPTY_ROWS)

     * Output the HTML.
     CALL RW_PUT(HTML)

     * Complete the page.
     CALL RW_END_PAGE
RETURN

The style sheet, table.css, includes the following style definitions:

body {
	font-family: Arial, Helvetica;
	font-size: 11pt;
	color: #006600;
	background-image: url('wb01256_.gif');
}
table {
	table-border-color-light: rgb(153,204,153);
	table-border-color-dark: rgb(153,204,153); 
}
h2 {
	font-family: Arial, Helvetica;
	color: rgb(204,153,51); 
}
td.gray {
	background-color: silver;
}
td.white {
	background-color: white;
}
th {
	background-color: darkseagreen;
}

Go to top button